int servoPin = 13;	
int servoPin1 = 12;
int minPulse = 500;   
int maxPulse = 2500;  
int pulse = 0;	 

// the time in milliseconds of last pulse
int lastPulse = 0;   
int refreshTime = 20; 

int analogValue = 0;  
int analogPin = 2;    

void setup() {
  pinMode(servoPin, OUTPUT);  
 pinMode(servoPin1, OUTPUT);
  pulse = minPulse;		
 // Serial.begin(9600);
}

void loop() {
  analogValue = analogRead(analogPin);   
  
  // length of pulse determines the servo position
  if (analogValue <= 50) pulse = minPulse;
  //if (analogValue >= 21 && analogValue <= 499) pulse = 0;
  if (analogValue >= 500 && analogValue <= 550) pulse = 1500;
  //if (analogValue >= 551 && analogValue <= 999) pulse = 0;
  if (analogValue >= 1000 && analogValue <= 1023) pulse = maxPulse;
  
  // for continuous motion alongside of potentiomter
  //pulse = (analogValue / 10) * 19 + 500;

  //Serial.print(minPulse, DEC);
  //Serial.print(maxPulse, DEC);
  //Serial.println(analogValue, DEC);  
  

  // pulse the servo again if rhe refresh time (20 ms) have passed:
  if (millis() - lastPulse >= refreshTime) {
    digitalWrite(servoPin, HIGH);   
    digitalWrite(servoPin1, HIGH);
    delayMicroseconds(pulse);	
    digitalWrite(servoPin, LOW);    
    digitalWrite(servoPin1, LOW);
    // save the time of the last pulse
    lastPulse = millis();	    
  }
}
